%-------------------------------------------------------------------------;
% Table 1: Monthly Returns (Annualized);
%-------------------------------------------------------------------------;

clear;
clc;
close all;

%-------------------;
% Import data;
%-------------------;

filename='Main_data_1996_2022';
[data,txt,raw]=xlsread(filename);

dates=txt(2:end,1);

%Index data;
SP_500=data(:,1);           %SP 500 index price level;
Div_m=data(:,2);            %Monthly index dividends;
Div_a=data(:,3);            %Annual index dividends;
SP_ret=data(2:end,4);       %Monthly return on SP 500 index;

%Dividend strip data;
Div_strip_12=data(:,5);     %Price of 12-month dividend strip;
Div_strip_ret=data(2:end,6);%Monthly return on dividend strip strategy;

%Indicated dividends;
Ind_div=data(1:end,7);  

%Bond returns;
Bond_2y=data(2:end,8);      %Monthly return on 2-year Treasury bond;
Bond_10y=data(2:end,9);     %Monthly return on 10-year Treasury bond;

%Fama-French data;
Mkt_Rf=data(2:end,10);      %Market factor;
Rf=data(2:end,11);          %Risk-free rate;

%Define dividend-to-price ratios;
DP_sp=Div_a./SP_500;
DP_strip=Div_a./Div_strip_12;

%Define indicated dividend growthh;
Ind_dg=(Ind_div./Div_a)-1;     

%Take logarithms of all the main variables;
ret_sp=log(SP_ret+1);
ret_strip=log(Div_strip_ret+1);

bond_2y=log(Bond_2y+1);  
bond_10y=log(Bond_10y+1);

mkt_rf=log(Mkt_Rf+1);
rf=log(Rf+1);

dp_sp=log(DP_sp);
dp_strip=log(DP_strip);

ind_dg=log(Ind_dg+1);

%-------------------------------;
% %Table 1: Monthly returns;
%-------------------------------;

% Columns 1&2: Log return;

[auto_sp,~,~]=autocorr(ret_sp);
[auto_strip,~,~]=autocorr(ret_strip);

Tab_1(1:2,1)=[mean(ret_sp)*1200;std(ret_sp)*sqrt(12)*100];
Tab_1(3:5,1)=[NaN;auto_sp(2,1);length(ret_sp)];

Tab_1(1:2,2)=[mean(ret_strip)*1200;std(ret_strip)*sqrt(12)*100];
Tab_1(3:5,2)=[NaN;auto_strip(2,1);length(ret_strip)];

% Columns 3&4: Minus rf;

ret_sp_ex=ret_sp-rf;
ret_strip_ex=ret_strip-rf;

[auto_sp_ex,~,~]=autocorr(ret_sp_ex);
[auto_strip_ex,~,~]=autocorr(ret_strip_ex);

Tab_1(1:2,3)=[mean(ret_sp_ex)*1200;std(ret_sp_ex)*sqrt(12)*100];
Tab_1(3:5,3)=[Tab_1(1,3)/Tab_1(2,3);auto_sp_ex(2,1);length(ret_sp_ex)];

Tab_1(1:2,4)=[mean(ret_strip_ex)*1200;std(ret_strip_ex)*sqrt(12)*100];
Tab_1(3:5,4)=[Tab_1(1,4)/Tab_1(2,4);auto_strip_ex(2,1);length(ret_strip_ex)];

% Columns 5&6: Minus Treasury ret;

ret_sp_ex=ret_sp-bond_10y;
ret_strip_ex=ret_strip-bond_2y;

[auto_sp_ex,~,~]=autocorr(ret_sp_ex);
[auto_strip_ex,~,~]=autocorr(ret_strip_ex);

Tab_1(1:2,5)=[mean(ret_sp_ex)*1200;std(ret_sp_ex)*sqrt(12)*100];
Tab_1(3:5,5)=[Tab_1(1,5)/Tab_1(2,5);auto_sp_ex(2,1);length(ret_sp_ex)];

Tab_1(1:2,6)=[mean(ret_strip_ex)*1200;std(ret_strip_ex)*sqrt(12)*100];
Tab_1(3:5,6)=[Tab_1(1,6)/Tab_1(2,6);auto_strip_ex(2,1);length(ret_strip_ex)];

disp('Table 1')
disp(Tab_1)
